<template>
	<view class="relative">
		<!-- <u-icon name="close" class='white absolute login_back' @click="backindex"></u-icon> -->
		<view class="absolute login_bg" style="">
			<image class="photo" src="../../static/index/loginBg.jpg" mode="aspectFit"></image>
		</view>
		<view class="" style="height: 270rpx;">

		</view>
		<view class="login p10" style="height:663px">
			<view class="radius-46 mt-60">
				<view class="size-26 ml-40">
					手机号
				</view>
				<u-field v-model="phone" :border-bottom="true" label-width="0" placeholder="请输入手机号登录"
					placeholder-style="color:#999;font-size:26rpx;">

				</u-field>
				<!-- <view class="tipsbox" v-if="isshow">手机号必填</view> -->
			</view>
			<!-- <view class="size-26 ml-40 mt-30">
				验证码
			</view>
			<view class="mt-40 radius-46 ">
				<u-field v-model="code" placeholder="请填写验证码">
					<u-button size="mini" slot="right" type="success" @click="getCode">{{codeText}}</u-button>
				</u-field>
				<u-verification-code ref="uCode" @change="codeChange"></u-verification-code>
			</view> -->
			
			<view class="size-26 ml-40 mt-30">
				密码
			</view>
			<view class="mt-40 radius-46 ">
				<u-field :password="true" v-model="code" placeholder="请填写密码">
					<!-- <u-button size="mini" slot="right" type="success" @click="getCode">{{codeText}}</u-button> -->
				</u-field>
				<!-- <u-verification-code ref="uCode" @change="codeChange"></u-verification-code> -->
			</view>
			
			<view class="ouaccount relative">

				<view class="mt-40" @click="submitUser()" style="">
					<u-button hover-class="none" class="custom-style" style="color: #FFF;" :style="{background:bg}"
						:hair-line="false" :disabled='bool'>登录
					</u-button>
				</view>
				<view class="flex">
					<view class="mt-30 size-28 newuser" @click="goregister">
						新用户注册
					</view>
					<view class="mt-30 size-28 newuser" @click="goForget" style="color: #000;">
						忘记密码
					</view>
				</view>
				<view class="mt-30 size-26 flex1 " style="align-items: center;">
					<u-checkbox-group @change="checkboxGroupChange">
						<u-checkbox shape="circle" @change="checkboxChange" v-model="item.checked"
							v-for="(item, index) in list" :key="index" :name="item.name">{{item.name}}</u-checkbox>
					</u-checkbox-group>
					<view class="login_che" @click="toAgreement">
						《用户服务协议》
					</view>
					<view class="login_che" @click="toPolicy">
						《隐私政策》
					</view>
				</view>
			</view>
		</view>
		<view class="recordbox" @click="todetail">备案号：浙ICP备2023004689号-2
			<!-- <view class="">海南奕空科技有限公司</view> -->
		</view>
	</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				checked: false,
				phone: '',
				mobile: '',
				code: '',
				codeText: '',
				bool: false,
				bg: ' linear-gradient(to right, #CDCDCD, #BEBEBE)',
				list: [{
					name: '已阅读并同意',
					checked: false,
					disabled: false
				}, ],
				// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中
				value: 'orange',
			}
		},
		methods: {
			todetail(){
				var url = 'https://beian.miit.gov.cn';
				// uni.navigateTo({
				// 	url: '../my/myWallet/webview?url=' + encodeURIComponent(JSON.stringify(url))
				// })
				window.location.href='https://beian.miit.gov.cn'
			},
			// 新用户注册
			goregister() {
				uni.navigateTo({
					url: '/pages/login/register'
				})
			},
			// 忘记密码
			goForget(){
				uni.navigateTo({
					url:"./forgetPsd"
				})
			},
			// 选中任一checkbox时，由checkbox-group触发
			checkboxGroupChange(e) {
				// console.log(e);
			},
			// 选中某个复选框时，由checkbox时触发
			checkboxChange(e) {
				// console.log(e.value);
				if (e.value) {
					this.bg = "linear-gradient(to right, #606060, #2B2B2B)"
					this.bool = true
					console.log(this.bool, this.bg, "开");

				} else {
					this.bg = "linear-gradient(to right, #CDCDCD, #BEBEBE)"
					this.bool = false
					console.log(this.bool, this.bg, "关");

				}
			},
			backindex() {
				uni.switchTab({
					url: '/pages/home/index'
				})
			},
			codeChange(text) {
				this.codeText = text;
			},
			getCode() {
				if (this.$refs.uCode.canGetCode) {
					// 模拟向后端请求验证码
					uni.showLoading({
						title: '正在获取验证码'
					})
					setTimeout(() => {
						uni.hideLoading();
						// 通知验证码组件内部开始倒计时
						this.$refs.uCode.start();
						console.log(111);
						this.$http('api/login/sendCode', {
							phone: this.phone,
							type: 3
						}, 'POST').then(res => {
							console.log(res);
						})
					}, 1000);
				} else {
					this.$u.toast('倒计时结束后再发送');
					console.log(1);
				}
			},
			submitUser() {
				if (this.code == '') {
					uni.showToast({
						title: '请输入密码',
						icon: 'none'
					})
				} else {
					this.$http('api/login/login', {
						phone: this.phone,
						password: this.code
					}, 'POST').then(res => {
						uni.showToast({
							title: '登录成功'
						})
						uni.setStorageSync("token", res.app_token)
						uni.setStorageSync("im_token", res.im_token)
						setTimeout(() => {
							uni.switchTab({
								url: '/pages/home/index'
							})
						}, 500)
					})
				}
			},
			toPolicy() {
				uni.navigateTo({
					url: '../my/policy'
				})
			},
			toAgreement() {
				uni.navigateTo({
					url: '../my/agreement'
				})
			},
		}
	}
</script>
<style lang="less" scoped>
	page{
		background-color: rgb(239,239,231);
	}
	::v-deep  .u-checkbox-group{
		width: 200rpx;
	}
	::v-deep  .u-checkbox__label{
		font-size: 26rpx;
	}
	.recordbox{
		width: 100%;
		position: fixed;
		bottom: 40rpx;
		text-align: center;
		color: #000;
		font-size: 20rpx;
	}
	.newuser {
		// background-color:#19BE6B;
		font-size: 12px;
		width: 100px;
		height: 25px;
		// color: #fff;
		text-align: center;
		line-height: 25px;
		border-radius: 7px;
		font-weight: bold;
	}


	.login_che {
		// color: #0813de;
		color: #00008B;
		font-size: 14rpx;
		font-weight: 600;
	}

	.login_bg {
		width: 100%;
		height: 400rpx;
		top: -10%;
		left: 50%;
		transform: translateX(-50%);
	}

	.login_back {
		width: 500rpx;
		height: 100rpx;
		top: 0%;
		left: 38%;
		transform: translateX(-50%);
	}

	.login {
		background-color: #fff;
		width: 100%;
		height: 1065rpx;
		border-radius: 30rpx 30rpx 0 0;
		position: absolute;
		top: 360rpx;
	}

	::v-deep  .u-field-inner {
		display: block;
	}

	.bottombox {

		// position: fixed;
		// bottom: 10rpx;
		.Login_agreement {
			color: #c8c8c8;
			font-size: 20rpx;
			display: flex;
			// margin-bottom: 20rpx;
		}
	}

	.policytext {
		font-size: 20rpx;
	}

	.ouaccount {
		width: 90%;
		height: 100rpx;
		border-radius: 20rpx;
		// position: fixed;
		bottom: 0%;
		left: 50%;
		// text-align: center;
		transform: translateX(-50%);


	}
</style>
